package com.egu.common.util;

import java.util.Map;

import org.apache.commons.mail.SimpleEmail;

import com.egu.model.Customer;
import com.egu.model.EmailInfo;

public class EmailUtil {

	public static void sendEmail(Map<String, Object> map) {
		EmailInfo emailInfo = (EmailInfo) map.get("emailInfo");
		Customer customer = (Customer) map.get("customer");
		try {
			// 邮件发送
			// 无附件邮件发送
			SimpleEmail email = new SimpleEmail();
			// 设置发送主机的服务器地址
			// email.setHostName("smtp.163.com");
			email.setHostName("smtp.qq.com");
			email.setSmtpPort(465);
			email.setSSL(true);
			// 设置收件人邮箱
			email.addTo(customer.getCustomerEmail(), customer.getCustomerName());
			// 发件人邮箱
			email.setFrom("251146651@qq.com", "东方教育客户关系管理系统");
			// 如果要求身份验证，设置用户名、密码，分别为发件人在邮件服务器上注册的用户名和密码
			// email.setAuthentication("shaolin5772@163.com", "SHAOlin5772");
			email.setAuthentication("251146651@qq.com", "bggcuyefbhoibgfd");// iogwkziowbricbdj nddegxvoppatbiii
			email.setCharset("utf-8");
			// 设置邮件的主题
			email.setSubject(emailInfo.getEmailTheme());
			// 邮件正文消息
			email.setMsg(emailInfo.getEmailContent());
			email.send();
		} catch (Exception e) {
			
		}
	}
}
